/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __CHR_MODEL_MANAGER_H__
#define __CHR_MODEL_MANAGER_H__

#include "GPrerequisites.h"

namespace GNgine
{
	class ChrModelRef
	{
	public:
		int Race;
		bool Sex;//true is male
		std::string ModelName;
		ChrModelRef(int race,bool sex,int modelName)
		{
			Race=race;
			Sex=sex;
			ModelName=modelName;
		}

	};

	class ChrModelManager
	{
	public:
		static const std::string PERSIS_FILE_NAME;
		
	protected:
		ChrModelManager();
	public:
		static ChrModelManager& getSingleton();
		int addChrRaceName(std::string raceName);
		int getChrRaceId(std::string raceName);

		void addChrModel(std::string raceName,std::string sex,std::string modelName);
		void addMaleChrModel(std::string raceName,std::string modelName);
		void addFemaleChrModel(std::string raceName,std::string modelName);
		void serialize();//save data to file system
		
		bool modelFileExist(std::string path);

		inline int getRaceCount()
		{
			return _raceNames.size();
		}

		inline std::string getRaceName(int index)
		{
			assert(index>=0&&index<_raceNames.size());
			return _raceNames[index];
		}
		//race id is the subscript of _raceNames
		inline int getRaceMaleModelCount(int race)
		{
			assert(race>=0&&race<_raceNames.size());
			return _maleModelNames[race].size();
		}

		inline std::string getRaceMaleModelName(int race,int index)
		{
			assert(race>=0&&race<_raceNames.size());
			assert(index>=0&&index<_maleModelNames[race].size());
			return _maleModelNames[race][index];
		}

		inline int getRaceFemaleModelCount(int race)
		{
			assert(race>=0&&race<_raceNames.size());
			return _femaleModelNames[race].size();
		}

		inline std::string getRaceFemaleModelName(int race,int index)
		{
			assert(race>=0&&race<_raceNames.size());
			assert(index>=0&&index<_maleModelNames[race].size());
			return _femaleModelNames[race][index];
		}

	private:
		std::vector<std::string> _raceNames;//vector size are equ
		std::vector<std::vector<std::string>> _maleModelNames;//very strange use
		std::vector<std::vector<std::string>> _femaleModelNames;
	};

}
#define GNgChrModelMgr GNgine::ChrModelManager::getSingleton()
#endif
